﻿using DataTurnClient.Interface;
using Splat;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataTurnClient.Server
{
    public class DBHelperService : IDBHelperService
    {
        public DBHelperService()
        {
        }
        public SqlSugarClient SqlSugarClient(string conn, DbType dbType)
        {
            
            SqlSugarClient sqlSugar = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = conn,
                DbType = dbType,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            });
            return sqlSugar;
        }

        public void DataCodeCopy<T>(SqlSugarClient con)
        {
            using (var db = con)
            {
                db.CodeFirst.SetStringDefaultLength(500).InitTables(typeof(T));
            }
        }
    }
}
